<template>
  <div class="customer-services">
      <!-- 客服电话设置 -->
      <div class="container">
        <div class="model-title text-overflow">客服电话设置</div>
        <div class="form-box">
          <el-form :model="phoneForm" ref="phoneForm" label-width="100px">
            <el-form-item label="贴牌id">
              <el-select v-model="phoneForm.brand_id">
                  <el-option
                    v-for="item in brandList"
                    :key="item.id"
                    :value="item.id"
                    :label="item.name"
                  ></el-option>
               </el-select>
            </el-form-item>
            <el-form-item label="客服电话">
              <el-input placeholder="请输入客服电话" v-model="phoneForm.brand_phone" ></el-input>
            </el-form-item>
            <div style="text-align:center">
              <el-button type="danger" @click="submitUpate">提交修改</el-button>
            </div>
          </el-form>
        </div>
      </div>
  </div>
</template>

<script>
export default {
  name:'customer-services',
  data () {
    return {
        phoneForm:{
          brand_id:null,
          brand_phone:null
        },
        brandList:[]
    };
  },
  components: {},
  created() {
    this.getBrandList();
  },
  mounted() {},
  methods: {
    getBrandList(){
      let url = `user/brand/query/all`;
      this.$Http.get(url).then(res=>{
        if(res.data.resp_code === "000000"){
          this.brandList = res.data.result;
        }else{
           this.$notify.info({
              title: '提示',
              message: res.data.resp_message
          });
        }
      }).catch(err=>{
        this.$notify.error({
            title: '提示',
            message: "获取品牌信息失败！"
        });
      })
    },
    submitUpate(){
      // 提交修改
      let url = `user/brand/phone/update/id`,
          params = `brand_id=${this.phoneForm.brand_id}&brand_phone=${this.phoneForm.brand_phone}`;
      this.$Http.post(url,params).then(res=>{
        if(res.data.resp_code === "000000"){
          // 修改成功
        }
        this.$notify.info({
          title:"提示",
          message:res.data.resp_message || "修改成功！"
        })
      }).catch(err=>{
        this.$notify.error({
            title: '提示',
            message: "提交修改信息失败！"
        });
      })
    }
  }
}

</script>
<style scoped>
.form-box{
  padding: 20px;
}
</style>